package com.offcn.bigdata.dataset

import org.apache.flink.api.scala._
/**
 * @Auther: BigData-LGW
 * @ClassName: CsvFlieSoure
 * @Date: 2020/12/15 21:11
 * @功能描述: $FunctionDescription
 * @Version:1.0
 */
object CsvFlieSoure {
    def main(args: Array[String]): Unit = {
        val env = ExecutionEnvironment.getExecutionEnvironment
        val lines = env.readCsvFile[Student](
            filePath = "file:/F:/student.csv",
            ignoreFirstLine = true,
            fieldDelimiter = "|"
        )
        val ret:DataSet[Result] = lines.map(stu => Result(stu.id,stu.name,stu.score))
            .groupBy(result => result.name)
            .maxBy(2)
        ret.print()
    }
}
case class Result(id:Int, name: String, score: Double)
case class Student(id: Int, name: String, age: Int, gender: String, course: String, score: Double)
